﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PServiceBus.Core.Interface;
using PServiceBus.Core.Runtime.Configuration;
using Phoenix.ReflectionExtensions;
using PServiceBus.Core.Configuration;

namespace PServiceBus.Core.Manager {
    public static class SecurityManager {

        private static IAuthorizationProvider _authorizationProvider = null;
        public static IAuthorizationProvider AuthorizationProvider {
            get {
                var securityConfig = ConfigurationProvider.SecurityConfig;
                return _authorizationProvider ?? (_authorizationProvider = DynamicBroker.Broker[securityConfig.AuthorizationType].New() as IAuthorizationProvider);
            }
        }

        private static IAuthenticationProvider _authenticationProvider = null;
        public static IAuthenticationProvider AuthenticationProvider {
            get {
                var securityConfig = ConfigurationProvider.SecurityConfig;
                return _authenticationProvider ?? (_authenticationProvider = DynamicBroker.Broker[securityConfig.AuthenticationType].New() as IAuthenticationProvider);
            }
        }
    }
}
